<template>
 <div>
    <HtmlPanel :url="url"> </HtmlPanel>
 </div>
</template>
<script>
import API from '@/utils/backend_api'
import HtmlPanel from '@/components/HtmlPanel'
export default {
  name: 'candidateOrigin',
  components: { HtmlPanel },
  props: {
    id: {
      type: String,
      default: '' // 这样可以指定默认的值
    }
  },
  data() {
    return {
      url: '',
      language_level_group: [],
      skill_certificate_group: [],
      preferred_city_group: [],
      desc_info: {}
    }
  },
  filters: {
  },
  watch: {
    id: function(val, oldVal) {
      console.log('当前值为：' + val, '旧值为：' + oldVal)
      if (val) {
        API.candidate.get(val).then(response => {
          this.desc_info = response.data
          if (this.desc_info.language_level_group) {
            this.language_level_group = JSON.parse(this.desc_info.language_level_group)
          }
          if (this.desc_info.skill_certificate_group) {
            this.skill_certificate_group = JSON.parse(this.desc_info.skill_certificate_group)
          }
          if (this.desc_info.preferred_city_group) {
            this.preferred_city_group = JSON.parse(this.desc_info.preferred_city_group)
          }
          if (this.desc_info.html_url) {
            console.log('html_url:', this.desc_info.html_url)
            this.url = this.desc_info.html_url
          } else {
            this.url = ''
          }
        })
      }
    }
  },
  created() {
    if (this.id) {
      API.candidate.get(this.id).then(response => {
        this.desc_info = response.data
        if (this.desc_info.language_level_group) {
          this.language_level_group = JSON.parse(this.desc_info.language_level_group)
        }
        if (this.desc_info.skill_certificate_group) {
          this.skill_certificate_group = JSON.parse(this.desc_info.skill_certificate_group)
        }
        if (this.desc_info.preferred_city_group) {
          this.preferred_city_group = JSON.parse(this.desc_info.preferred_city_group)
        }
        if (this.desc_info.html_url) {
          console.log('html_url:', this.desc_info.html_url)
          this.url = this.desc_info.html_url
        } else {
          this.url = ''
        }
      })
    }
  },
  methods: {
  }
}
</script>
<style scoped>

</style>
